package com.zudada.servermain.POJO.enums;

import io.jsonwebtoken.io.Decoders;
import io.jsonwebtoken.security.Keys;
import lombok.extern.slf4j.Slf4j;
import org.apache.tomcat.util.codec.binary.Base64;

import javax.crypto.SecretKey;

/**
 * SignWithUtil
 *
 * @author Chopper
 * @version v1.0
 * 2020-11-18 17:30
 */
@Slf4j
public class SecretKeyUtil {
    public static SecretKey generalKey() {
        //自定义
        byte[] encodedKey = Base64.decodeBase64("cuAihCz53DZRjZwbsGcZJ2Ai6At+T142uphtJMsk7iQ=");
        SecretKey key = Keys.hmacShaKeyFor(encodedKey);
      log.info(key.toString());
        return key;
    }

    public static SecretKey reflushgeneralKey() {
        //自定义
        byte[] encodedKey = Base64.decodeBase64("cuAihCz53DZRjZwbsdsfGcZJ2Ai6Asdft+T142uphtJMsk7iQ=reflush");
        SecretKey key = Keys.hmacShaKeyFor(encodedKey);
        return key;

    }

    public static SecretKey AdminKey() {
        //自定义
        byte[] encodedKey = Base64.decodeBase64("cuAihCz53DZRj53Zwbs6dsfGc4ZJdft+sas5snvidsinj=Admin");
        SecretKey key = Keys.hmacShaKeyFor(encodedKey);
        return key;

    }

    public static SecretKey generalKeyByDecoders() {
        return Keys.hmacShaKeyFor(Decoders.BASE64.decode("cuAihCz53DZRjZwbsGcZJ2Ai6At+T142uphtJMsk7iQ="));
    }
}
